package com.glsc.ngateway.common.base.domain.convert;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

@Converter(autoApply = true)
public class LocalTimeAttributeConverter_8 implements AttributeConverter<LocalTime, String> {

    static DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HH:mm:ss");

    @Override
    public String convertToDatabaseColumn(LocalTime time) {
        return time == null ? null : dtf.format(time);
    }

    @Override
    public LocalTime convertToEntityAttribute(String time) {
        return time == null ? null : LocalTime.parse(time,dtf);
    }

}
